package com.sangeng.controller;

import com.sangeng.domain.dto.AddUserDTO;
import com.sangeng.domain.dto.UserSearchParamsDTO;
import com.sangeng.domain.vo.Result;
import com.sangeng.domain.vo.UserListVO;
import com.sangeng.service.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/system/user")
@Slf4j
public class UserController {
    @Resource
    private IUserService userService;

    /**
     * 添加用户
     */
    @PostMapping("/add")
    public Result<String> addUser(@RequestBody AddUserDTO addUserDTO){
        log.info("添加用户,{}",addUserDTO);
        return userService.addUser(addUserDTO);
    }

    /**
     * 分页查询用户信息
     */
    @PostMapping("/list")
    public Result<UserListVO> pageList(@RequestBody UserSearchParamsDTO userSearchParamsDTO){
        log.info("分页查询,{}",userSearchParamsDTO);
        return userService.pageList(userSearchParamsDTO);
    }
}
